package com.ygl.strategy.service.configuration;

import com.ygl.strategy.constant.StrategyConstant;
import com.ygl.strategy.service.tracer.ServiceStrategyTracerInterceptor;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author yanggld
 * @Date 2019/12/31-15:44
 * @Description
 */
@Configuration
@ConditionalOnProperty(value = StrategyConstant.SPRING_APPLICATION_STRATEGY_TRACE_ENABLED, matchIfMissing = false)
public class WebMvcConfiguration implements WebMvcConfigurer {

	@Autowired
	private ServiceStrategyTracerInterceptor serviceStrategyTracerInterceptor;

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(serviceStrategyTracerInterceptor)
				.addPathPatterns("/**")
				.order(0);
	}

}
